/*
 * @lc app=leetcode.cn id=101 lang=javascript
 *
 * [101] 对称二叉树
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
var isSymmetric = function (root) {
  const res = []
  if (root === null) {
    return false
  }
  const queque = []
  queque.push(root.left)
  queque.push(root.right)
  while (queque.length) {
    const left = queque.shift()
    const right = queque.shift()
    if (left === null && right === null) {
      continue
    }
    if (left === null || right === null || left.val !== right.val) {
      return false
    }
    queque.push(left.left)
    queque.push(right.right)
    queque.push(left.right)
    queque.push(right.left)
  }
  return true
};
// @lc code=end

